package xyz.ddlnt.servicemgclient.client.fallback;

import org.springframework.cloud.openfeign.FallbackFactory;
import xyz.ddlnt.commonutil.enumeration.ResultCode;
import xyz.ddlnt.commonutil.exception.GlobalException;
import xyz.ddlnt.commonutil.result.Result;
import xyz.ddlnt.model.dto.CategoryDTO;
import xyz.ddlnt.model.entity.Category;
import xyz.ddlnt.servicemgclient.client.CategoryFeignClient;

import java.time.LocalDateTime;
import java.util.List;


/**
 * @author ZZULI_SE 210910
 * @data 2025/4/29 22:22
 */
public class CategoryFallbackFactory  implements FallbackFactory<CategoryFeignClient> {
    @Override
    public CategoryFeignClient create(Throwable cause) {
        return new CategoryFeignClient() {
            @Override
            public Result<List<Category>> getAllCategory() {
                throw new GlobalException(ResultCode.THE_REMOTE_PROCEDURE_CALL_FAILED);
            }

            @Override
            public Result<List<CategoryDTO>> getAllCategoryName() {
                throw new GlobalException(ResultCode.THE_REMOTE_PROCEDURE_CALL_FAILED);
            }

            @Override
            public Result<Category> addCategory(String categoryName) {
                throw new GlobalException(ResultCode.THE_REMOTE_PROCEDURE_CALL_FAILED);
            }

            @Override
            public Result<String> deleteCategory(Long id) {
                throw new GlobalException(ResultCode.THE_REMOTE_PROCEDURE_CALL_FAILED);
            }

            @Override
            public Result<LocalDateTime> updateCategory(CategoryDTO categoryDTO) {
                throw new GlobalException(ResultCode.THE_REMOTE_PROCEDURE_CALL_FAILED);
            }
        };
    }
}
